/**
 * 2015年9月17日上午8:59:42
 * RoadLostSched.javaRoadLostSched
 */
package com.service.scheduler.sched;

import org.quartz.CronTrigger;
import org.quartz.JobDetail;
import org.quartz.JobKey;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.Trigger;
import org.quartz.TriggerKey;
import com.service.cache.CacheManager;
import com.service.other.Logger;
import com.service.scheduler.job.NoticeMessageJob;
import com.service.scheduler.server.SchedulerCreator;

/**
 * 2015年9月17日上午8:59:42
 *
 * wt
 * 报警消息发送
 * 
 */
public class NoticeMessageSched {

	private Scheduler noticeMessageSched;
	
	public void init() {
		try {
			noticeMessageSched = SchedulerCreator.createScheduler(NoticeMessageSched.class.getSimpleName(), 1, Trigger.DEFAULT_PRIORITY);
			initNoticeMessage();
			CacheManager.instance().schedMap.put(noticeMessageSched.getSchedulerName(), noticeMessageSched);
		} catch (SchedulerException e) {
			Logger.err(e);
		}
	}

	/**
	 * @throws SchedulerException 
	 * 
	 */
	private void initNoticeMessage() throws SchedulerException {
		JobKey jobKey = SchedulerCreator.createJobKey("noticeMessageSched","com.service.cache");
		TriggerKey triggerKey = SchedulerCreator.createTriggerKey("noticeMessageSched", "com.service.cache");
		//String cronExpr = "0 0 0 * * ?";
		String expr = SchedulerCreator.createSecondExpr(20);
		JobDetail jd = SchedulerCreator.createJob(jobKey, NoticeMessageJob.class);
		CronTrigger ct = SchedulerCreator.createCronTrigger(triggerKey, expr);
		noticeMessageSched.scheduleJob(jd, ct);
	}
	
}
